using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.DirectX.DirectDraw;

namespace Zsa.Emulation.Render.Video.DirectDraw
{
    /// <summary>
    /// Settings used to create a direct 3d device
    /// </summary>
    public class DirectDrawRenderSettings : GraphicRenderSettings
    {

        #region Fields

        private CreateFlags _CreateFlags;

        private CooperativeLevelFlags _CooperativeFlags;

       
        #endregion Fields

        #region Constructor
        /// <summary>
        /// Initializes a new instance of the <see cref="T:D3dRenderSettings"/> class.
        /// </summary>
        /// <param name="item">The item.</param>
        public DirectDrawRenderSettings(RenderDeviceItem item)
            : base ( item )
        {
            _CooperativeFlags = CooperativeLevelFlags.Normal;
        }
        #endregion Constructor

        #region Properties
        /// <summary>
        /// Gets a value indicating whether this instance is device specific.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if this instance is device specific; otherwise, <c>false</c>.
        /// </value>
        public bool IsDeviceSpecific
        {
            get
            {

                return DeviceGuid != Guid.Empty;
                
            }
        }

        /// <summary>
        /// Gets the device GUID.
        /// </summary>
        /// <value>The device GUID.</value>
        public Guid DeviceGuid
        {
            get
            {    
                if ((base.DeviceItem.Id is Guid))
                {
                    Guid _Guid = (Guid)base.DeviceItem.Id;    
                    return _Guid;
                }
                return Guid.Empty;
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether [use emulation].
        /// </summary>
        /// <value><c>true</c> if [use emulation]; otherwise, <c>false</c>.</value>
        public bool UseEmulation
        {
            get
            {
                return (_CreateFlags & CreateFlags.EmulationOnly) == CreateFlags.EmulationOnly;
            }
            set
            {
                if (value)
                {
                    _CreateFlags = CreateFlags.EmulationOnly;
                }
                else
                {
                    _CreateFlags = CreateFlags.Default;
                }
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether [use hardware].
        /// </summary>
        /// <value><c>true</c> if [use hardware]; otherwise, <c>false</c>.</value>
        public bool UseHardware
        {
            get
            {
                return (_CreateFlags & CreateFlags.HardwareOnly) == CreateFlags.HardwareOnly;
            }
            set
            {
                if (value)
                {
                    _CreateFlags = CreateFlags.HardwareOnly;
                }
                else
                {
                    _CreateFlags = CreateFlags.Default;
                }
            }
        }

        /// <summary>
        /// Gets the create flags.
        /// </summary>
        /// <value>The create flags.</value>
        public CreateFlags CreateFlags
        {
            get
            {
                return _CreateFlags;
            }
        }

        /// <summary>
        /// Gets the cooperative level flags.
        /// </summary>
        /// <value>The cooperative level flags.</value>
        public CooperativeLevelFlags CooperativeLevelFlags
        {
            get
            {
                return _CooperativeFlags;
            }
        }

        #endregion Properties


        //public override GraphicRender CreateD()
        //{
        //    return new DirectDrawGraphicRender();
            
        //}



        public override bool IsValid()
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public override GraphicRenderCapabilities Capabilities
        {
            get 
            { 
                throw new Exception("The method or operation is not implemented."); 
            }
        }




        public override GraphicRenderSettings Clone()
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public override GraphicRender CreateDevice()
        {
            DirectDrawGraphicRender render = new DirectDrawGraphicRender(this);
            return render;
        }

        public override bool Equals(GraphicRenderSettings other)
        {
            throw new Exception("The method or operation is not implemented.");
        }
    }
}
